package com.gaohe.official.controller;

import java.util.List;
import java.io.IOException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gaohe.common.log.annotation.Log;
import com.gaohe.common.log.enums.BusinessType;
import com.gaohe.common.security.annotation.RequiresPermissions;
import com.gaohe.official.domain.FmFinance;
import com.gaohe.official.service.IFmFinanceService;
import com.gaohe.common.core.web.controller.BaseController;
import com.gaohe.common.core.web.domain.AjaxResult;
import com.gaohe.common.core.utils.poi.ExcelUtil;
import com.gaohe.common.core.web.page.TableDataInfo;

/**
 * 财务情况Controller
 * 
 * @author ruoyi
 * @date 2025-06-03
 */
@RestController
@RequestMapping("/finance")
public class FmFinanceController extends BaseController
{
    @Autowired
    private IFmFinanceService fmFinanceService;

    /**
     * 查询财务情况列表
     */
    @RequiresPermissions("official:finance:list")
    @GetMapping("/list")
    public TableDataInfo list(FmFinance fmFinance)
    {
        startPage();
        List<FmFinance> list = fmFinanceService.selectFmFinanceList(fmFinance);
        return getDataTable(list);
    }

    /**
     * 导出财务情况列表
     */
    @RequiresPermissions("official:finance:export")
    @Log(title = "财务情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FmFinance fmFinance)
    {
        List<FmFinance> list = fmFinanceService.selectFmFinanceList(fmFinance);
        ExcelUtil<FmFinance> util = new ExcelUtil<FmFinance>(FmFinance.class);
        util.exportExcel(response, list, "财务情况数据");
    }

    /**
     * 获取财务情况详细信息
     */
    @RequiresPermissions("official:finance:query")
    @GetMapping(value = "/{financeId}")
    public AjaxResult getInfo(@PathVariable("financeId") Long financeId)
    {
        return success(fmFinanceService.selectFmFinanceByFinanceId(financeId));
    }

    /**
     * 新增财务情况
     */
    @RequiresPermissions("official:finance:add")
    @Log(title = "财务情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FmFinance fmFinance)
    {
        return toAjax(fmFinanceService.insertFmFinance(fmFinance));
    }

    /**
     * 修改财务情况
     */
    @RequiresPermissions("official:finance:edit")
    @Log(title = "财务情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FmFinance fmFinance)
    {
        return toAjax(fmFinanceService.updateFmFinance(fmFinance));
    }

    /**
     * 删除财务情况
     */
    @RequiresPermissions("official:finance:remove")
    @Log(title = "财务情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{financeIds}")
    public AjaxResult remove(@PathVariable Long[] financeIds)
    {
        return toAjax(fmFinanceService.deleteFmFinanceByFinanceIds(financeIds));
    }
}
